package com.jht.pj.sys.controller;

import com.jht.pj.common.pojo.JsonResult;
import com.jht.pj.common.pojo.PageObject;
import com.jht.pj.sys.pojo.Song;
import com.jht.pj.sys.service.SongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/song/")
public class SongController {

    @Autowired
    private SongService songService;

    //http://localhost/song/doFindPageSong
    @GetMapping("doFindPageSong")
    public JsonResult doFindPageSong(Integer pageCurrent){
        return new JsonResult(songService.findPageSong(pageCurrent));
    }

    //http://localhost/song/countSong
    @GetMapping("countSong")
    public JsonResult countSong(){
        int rows = songService.countSong();
        System.out.println(rows);
        return new JsonResult("find ok");
    }
    //http://localhost/song/findSong
    @GetMapping("findSong")
    public JsonResult findSong(){
        return new JsonResult(songService.findSong());
    }

    //http://localhost/song/findSongById
    @GetMapping("findSongById")
    public JsonResult findSongById(Integer id){
        return new JsonResult(songService.findSongById(id));
    }

    //http://localhost/song/findSongByName
    @GetMapping("findSongByName")
    public JsonResult findSongByName(@RequestParam String name){

        return new JsonResult(songService.findSongByName(name));
    }
    //http://localhost/song/findSongByConcat
   /* @GetMapping("findSongByConcat/{name}")
    public JsonResult findSongByConcat(String name){
        return new JsonResult(songService.findSongByConcat(name));
    }*/
}
